package org.example.controller.advice;

import org.springframework.security.access.AccessDeniedException;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * 异常处理
 *
 */
@ControllerAdvice
public class ExceptionAdvice {

    //针对没有权限访问异常
    @ExceptionHandler(AccessDeniedException.class)
    public String exce(AccessDeniedException e, Model model){
        model.addAttribute("error",e.getMessage());
        return "403";
    }
}
